﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using EasyStudy.ProjectUpdate.DB;
using EasyStudy.ProjectUpdate.Model;

namespace EasyStudy.UI.ProjectUpdate
{
    public partial class FrmProjUpdateMain : Form
    {
        public FrmProjUpdateMain()
        {
            InitializeComponent();

            LoadProjects();
        }

        public void LoadProjects()
        {
            List<Project> projs = ProjectDBMgr.GetAllProjectsInfo();
            cmbProjects.Items.Clear();

            foreach (Project proj in projs)
            {
                cmbProjects.Items.Add(proj);
            }

            if (cmbProjects.Items.Count > 0)
            {
                cmbProjects.SelectedIndex = 0;
            }
        }

        private void btnAddProj_Click(object sender, EventArgs e)
        {
            FrmAddProject addProject = new FrmAddProject();

            if (addProject.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                LoadProjects();
                addProject.Close();
            }
            else
            {
                addProject.Close();
            }
        }

        private void btnOpen_Click(object sender, EventArgs e)
        {
            //FrmProject frmProj = new FrmProject();
            //frmProj.ShowDialog();
        }
    }
}
